g. Key, g => g. To..." />

Linq: Convert datatable rows to Dictionary

Here's one way you could do it in C#: var dict = resultTable.AsEnumerable() . GroupBy(row => row. Field("a")) .

ToDictionary( g => g. Key, g => g. ToDictionary( row => row.

Field("b"), row => row. Field("c") ) ) And equivalent VB: Dim dict = resultTable. AsEnumerable .

GroupBy(Function(row) row. Field(Of A)("a")) . ToDictionary( Function(g) g.

Key, Function(g) g. ToDictionary( Function(row) row. Field(Of B)("b"), Function(row) row.

Field(Of C)("c") ) ).

Here's one way you could do it in C#: var dict = resultTable.AsEnumerable() . GroupBy(row => row. Field("a")) .

ToDictionary( g => g. Key, g => g. ToDictionary( row => row.

Field("b"), row => row. Field("c") ) ); And equivalent VB: Dim dict = resultTable. AsEnumerable .

GroupBy(Function(row) row. Field(Of A)("a")) . ToDictionary( Function(g) g.

Key, Function(g) g. ToDictionary( Function(row) row. Field(Of B)("b"), Function(row) row.

Field(Of C)("c") ) ).

Frankly, I think you should strive for a Dictionary, C>: var dict = resultTable.AsEnumerable() . GroupBy(row => Tuple. Create( row.

Field("a"), row. Field("b") ) ) . ToDictionary( group => group.

Key, group => group.Single(). Field("c") ).

While I agree, C# doesn't make using it any easier. In its "raw" form, using it is very awkward. It becomes more bearable supplemented with supporting extension methods or derived types.

If only there was a real tuple syntax in the language... – Jeff Mercado Aug 26 at 22:07.

GroupBy( dr => dr.Field("key") ). Grp => grp. Grp => grp.

GroupBy( keyConverter ). Grp => grp. Grp => grp.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.